#include<bits/stdc++.h>
using namespace std;

class Solution {
public:
    long long minimumTime(vector<int>& time, int totalTrips) {
        int min_val = 10000001;
        for(int i = 0; i < time.size(); i++)min_val = min(min_val, time[i]);
        long long low = 0, high = (long long)totalTrips * (long long)min_val;
        while(low < high){
            int mid = (low + high) / 2;
            int temp = 0;
            for(int i = 0; i < time.size(); i++){
                temp += mid / time[i];
            }
            if(temp >= totalTrips)high = mid;
            else low = mid + 1;
        }
        return low;
    }
};
/**
 * @brief 2022.2.27
 * 周赛
 */